home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 30.5 KB | 823 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: StandardFile.Lib
- #
- # Contains: Tasks that support Standard File operations.
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.27> 12/16/93 KTA ModifyDocument was not returning correct values.
- # <1.0.26> 12/14/93 KTA Changed the way ModifyDocuemtn handles return values.
- # <1.0.25> 12/13/93 KTA OpenFile returns the name of the file it opened.
- # <1.0.24> 11/19/93 NAGA modify TCS format
- # <1.0.23> 10/05/93 KTA Revert() - Added longer wait before trying to dismiss dialog and
- # support for hierachical menus
- # <1.0.22> 10/05/93 KTA ModifyDocument() - Change returnVal to a 1 if it was successful.
- # <1.0.21> 9/30/93 KTA SaveAs() - Updated the output after saving a document.
- # <1.0.20> 9/28/93 KTA ModifyDocument() - Added TCS - 'Modify a Document'
- # <1.0.19> 9/28/93 KTA ModifyDocument() - Handle problem caused if gModifyDocument hook doesn't return a value
- # <1.0.18> 9/22/93 KTA Renamed gSaveOtherFormat -> SaveAsHook1, gEndTimer -> SaveAsHook2
- # gDismissSFPut -> gSaveAsHook3,gOpenFileHook -> gOpenFileHook1,
- # gEndTimer ->gOpenFileHook2, Removed pParameter1 from OpenFile()
- # <1.0.17> 9/14/93 KTA SaveAs() - gCustomRetrievedDoc wasn't being used
- # because it was not defined as global.
- # <1.0.16> 9/9/93 KTA Removed all slang phrases from output.
- # <1.0.15> 8/30/93 KTA Updated task headers and parameters.
- # <1.0.14> 8/25/93 KTA Added support for parity checking the TCS stack.
- # <1.0.13> 7/30/93 KTA IsStandardFile - return window descriptor, ModifyDocument return
- # success/Failure. Openfile better check if standardfile gone.
- # <1.0.12> 7/23/93 KTA SaveAs() - moved gDismissSFPut to before we verify filename.
- # <1.0.11> 7/22/93 KTA Fixed bugs with file name verificaton, SaveAS(), OpenFile().
- # <1.0.10> 7/19/93 KTA FindWindow() now supports descriptors - updated references.
- # <1.0.9> 7/15/93 KTA Added undefined task reference - gReplaceExisting. Hook to
- # handle a custom "replace existing?" dialog. This was done for Lotus 123.
- # <1.0.8> 7/14/93 KTA International Support: See SaveAs(), OpenFile(),
- # CancelStandardFile(), Revert(), and Save().
- # <1.0.7> 7/6/93 KTA CustomRetrieveDoc change had a syntax error
- # <1.0.6> 7/6/93 KTA Performance Support
- # <1+> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "String.Lib","TCS.Lib","Output.Lib","UserInterface.Lib";
-
-
-
-
- #########################################################################
- # SaveAs(pNameDoc, pReplaceFlag, pSelectSaveAs, pPathlist)
- #========================================================================
- # Author: KTA
- # Description: This routine will type a name (pNameDoc) into the text edit
- # field. Then it will press the ReturnKey to save the file.
- # If there is a document already named <pNameDoc> a dialog will
- # appear. If the <pReplaceFlag> evaluates to false
- # it will select NO to 'Replace Existing?' dialog. It will
- # then type the time (based on a 24 hour clock) after the
- # name and retype the ReturnKey. The Default is to replace
- # an existing document with the same name. It will also call
- # getNewFileName to create a file name if one is not provided.
- # Parameters: pNameDoc - string holding the name to name the document
- # pReplaceFlag - 0 to select 'No' to 'Replace Existing' dialog
- # 1 to select 'Yes' to replace exisiting file.
- # pSelectSaveAs - Flag which indicates whether or not to select
- # SaveAs menuItem.
- # 0 - Do not select SaveAs MenuItem
- # 1 - Select the SaveAs menuItem
- # {List} - Select the SaveAs menuItem using the
- # ord specified. e.g. {5,2}
- # pPathlist - Path to navigate before saving - should be complete path.
- # Returns: 0 - Unable to dismiss SFPut or never present to begin with
- # 1 - Dismissed SFPut ok, saved file, ReplaceExist not called
- # 2 - Dismissed SFPut ok, saved file, ReplaceExist called
- # Examples: SaveAs('Untitled1'); to name the file 'Untitled1'
- # Assumptions: That the SF_Put dialog is present
- #
- #========================================================================
- # History:
- # KTA 7/06/93 Performance Support: EndTimer
- # KTA 7/07/93 Ability to pass in saveAs menu, if pSelectSaveAs is list of menuItems
- # KTA 7/13/93 Added undefined task reference gReplaceExisitng
- # KTA 7/19/93 Changed call to FindWindow() to pass a descriptor.
- # KTA 7/22/93 if can't match (gActualFileName) reassign to string we typed
- # KTA 8/24/93 TCS stack parity check
- # KTA 9/14/93 gCustomRetrievedDoc wasn't being used because it was not
- # defined as global
- # KTA 9/22/93 Changed gSaveOtherFormat to gSaveAsHook1
- # Changed gEndTimer to gSaveAsHook2
- # Changed gDismissSFPut to gSaveAsHook3
- # KTA 9/30/93 Updated the output after saving a document.
- #########################################################################
- TASK SaveAs(pNameDoc := "", pReplaceFlag := true, pSelectSaveAs := False, pPathlist := global gSFPUTLocation)
- begin
- global gIsSys7, gLastSavedFile, gActualFileName;
- returnVal := 0;
-
- if (pSelectSaveAs)
- begin
- TCSStart({ 1, global kTCSetSFSave },"SaveAs"); # Start TCS
- if(typeOf(pSelectSaveAs) = 'list')
- thisReturn := selectmenuItem(pSelectSaveAs[1],pSelectSaveAs[2]);
- else
- thisReturn := selectmenuItem("Save As", "File");
- TCSEnd({ 1, global kTCSetSFSave },thisReturn); # Select the MenuItem
- end;
-
- wait(2);
- ## Check to see if Standard File is present
- if (IsStandardFile())
- begin
- SFPutDesc:= match[window o:1]!; # Save off the descriptor
-
- LogStr("############## Standard File - Save ##############");
- if (pNameDoc = "")
- pNameDoc := GetNewFileName(); #To get a name
-
- if (pPathlist) and (IsSys7) # No navigating in 6.0
- SFNavigate( pPathlist ,1);
-
- if (global gSaveAsHook1) # app specific hook
- call (gSaveAsHook1); # Useful for saving in other formats
-
- TypeStr(pNameDoc); # Type the name of the Document
- SpecialKey(ReturnKey, 'Return Key'); # Accept the SF dialog
-
- wait(3);
- if (global gReplaceExisting)
- Call(gReplaceExisting,pReplaceFlag,pNameDoc);
- else
- begin
- ## 7.0 and 6.0 have different 'Replace Existing' dialogs
- ## Determine if Replace Existing Dialog is present
- ReplaceExisting := collect[button w:[window o:1]];
- if (Card(ReplaceExisting) = 2)
- begin
- pNameDoc := ReplaceExist(pReplaceFlag, pNameDoc);
- returnval:= 2;
- end;
- else
- DialogCheck("",1); # Look for other problems
- end;
-
- if (global gSaveAsHook2) # app specific hook
- Call (gSaveAsHook2); # This can be useful in performance testing
-
- if not FindWindow(SFPutDesc) # if we can't find SFPut Dialog, indicates saved document for 1st time
- if not returnval # if not already reset from replace exist
- begin
- returnVal := 1; # set to success - no replace exist done
- TCSStart({ 2, global kTCSetSFSave },"Save a new file");
- TCSEnd({ 2, global kTCSetSFSave },1);
- end; # if not returnval
-
- if (global gSaveAsHook3) # app specific
- call (gSaveAsHook3); # hook for handling anything
-
- if (returnval)
- begin
- gLastSavedFile := pNameDoc;
- if (global gCustomRetrievedDoc)
- theFile := FindWindow(gCustomRetrievedDoc);
- else
- theFile := FindWindow(0);
-
- gActualFileName := theFile.t;
- if(gActualFileName)
- str := "The document's window is named - '{gActualFileName}'";
- else
- begin
- gActualFileName := pNameDoc;
- str := "The document is named - '{gActualFileName}'";
- end;
- LogStr(str);
- end;
- else
- logstr('Unable to dismiss the SFPut Dialog');
-
- end; # if (IsStandardFile())
-
- return(returnVal);
- end; # SaveAs()
-
- #########################################################################
- # OpenFile(pNameDoc,pSelectOpen, pPathList, pPartialPath)
- #========================================================================
- # Author: KTA
- # Description: This routine will select 'Open' from the 'File' menu, type
- # the string held in the pNameDoc parameter, and
- # then press the returnkey. It will check to see that
- # the frontmost window's title contains pNameDoc. If not,
- # it assumes that the wrong file opened. It will not select
- # 'Open' if the pSelectOpen parameter is false.
- # Parameters: pNameDoc - string name of document to open
- # pSelectOpen - 0 to disable selecting of the 'Open' menu item.
- # 1 to select 'Open' from the 'File' menu
- # 2 keyEq - 'o'
- # list - list containing ordinality of 'Open' menuItem.
- # pPathList - list defining path if file named <pNameDoc> not in
- # the current directory
- # pPartialPath := Whether to start navigation at the current dir or
- # at the desktop
- # 1 - start at current directory
- # 0 - start at desktop (not partial)
- # Returns: 1 - Document opened OK
- # 0 - Document not opened OK
- # Assumptions: Works with SF_Get, but don't have pNameDoc be to long
- # of a string.
- # Examples: OpenFile('Untit'); will select a document such as 'Untitled'.
- #========================================================================
- # History:
- # KTA 7/06/93 Performance support: OpenFileHook, EndTimer and
- # modified gCustomRetrievedDoc check
- # KTA 7/07/93 Ability to pass in open menu, if pSelectOpen is list of menuItems
- # Added global Actualfile so that we can do a better check to see if
- # the right file was opened. (intl)
- # KTA 7/22/93 added isSubString(pNameDoc,DocName) better filename verification
- # KTA 7/29/93 Changed check for StandardFile being Present
- # KTA 8/24/93 TCS stack parity check
- # KTA 9/9/93 Removed the slang 'BuckWheat' from the output line.
- # KTA 9/22/93 Changed gOpenFileHook to gOpenFileHook1
- # Changed gEndTimer to gOpenFileHook2
- # Removed gTimedEvent
- #########################################################################
- TASK OpenFile(pNameDoc := "", pSelectOpen := 1, pPathList :={}, pPartialPath := 0)
- begin
- global gIsSys7, gActualFileName;
- returnVal := 0;
- failStr := "";
- if(pNameDoc)
- begin
- TCSStart({ 1, global kTCSetOpenDoc },"OpenFile"); # Start TCS
-
- if (pSelectOpen)
- begin
- if (Typeof(pSelectOpen) = 'list')
- selectmenuItem(pSelectOpen[1], pSelectOpen[2]); # Select the Open menuItem for intl
- else if (pSelectOpen = 1)
- selectmenuItem("Open", "File"); # Select the Open menuItem
- else if (pSelectOpen = 2)
- KeyEq('o'); # Keyboard equivelant 'o' for open
- end;
- wait(2);
- SFDialog := IsStandardFile();
- if (SFDialog)
- begin
- LogStr( "############## Standard File - Open ##############");
- if ( pPathList ) and (global gIsSys7) # No navigating in 6.0
- SFNavigate(pPathList,,,pPartialPath);
-
- if(global gOpenFileHook1)
- call (gOpenFileHook1); # Hook to do whatever required prior to typing filename
-
- TypeStr(pNameDoc); # Type the name of the file to open
-
- SpecialKey(ReturnKey, 'Return Key'); # Accept the dialog
-
- if(global gOpenFileHook2)
- Call(gOpenFileHook2); # Hook can be used for Performance
- Wait(3);
-
- #### Check to make sure Standard file is no longer present
- if (FindWindow(SFDialog)) # Call but don't log that it's not there
- begin
- failStr := "!@#$% Standard File is still present and it shouldn't be";
- LogStr(failStr);
- KeyEq('.'); # Exit (changed from 'cancel' button - intl)
- end;
- else if (global gCustomRetrievedDoc)
- begin
- customDoc := match gCustomRetrievedDoc!;
- if(customDoc)
- begin
- DocName := customDoc.t;
- LogStr("The front window is named '{DocName}'");
- returnVal := 1; # return success
- end;
- else begin
- failStr := "!@#$% It appears that the wrong file was opened - {DocName}";
- LogStr(failStr);
- end;
- end; # else if global gCustomRetrievedDoc
- else # else do default doc checking
- begin
- ### match the top document window (Hopefully the Document that was just opened)
- theDoc := findWindow(0); # Match the document window
- DocName := theDoc.t;
- if not(DocName)
- LogStr("!@#$% No open window with grow and zoom boxes");
- else
- LogStr("The front document is named '{DocName}'");
-
- ## Is the document the one we expected
- if (isSubString(DocName,gActualFileName) or isSubString(pNameDoc,DocName)) # looks like the right file
- returnVal := 1; # return success
- else
- begin
- failStr := "!@#$% It appears that the wrong file was opened - {DocName}";
- LogStr(failStr);
- end;
- end; # else do default doc checking
- end; # if (IsStandardFile())
- TCSEnd({ 1, global kTCSetOpenDoc },returnVal,failStr,,{DocName});
- end;
- else
- LogStr("!@#$% No file name was specified");
-
- return(returnVal);
- end; # OpenFile()
-
- #########################################################################
- # SFNavigate(pPathList, pTEToggle, pFinalReturn, pPartialPath)
- #========================================================================
- # Author: KTA
- # Description: Controls the navigation in Standard File.
- # Assigns a global gSFOriginalPath to the current directory
- # for return navigation.
- # Passes all parameters to SFType which performs actual navigation.
- # Parameters: pPathList := List of directories beginning with the disk name.
- # pTEToggle := Whether toggling from a text edit field is required
- # to navigate.
- # 1 - Toggle
- # 0 - No toggling required
- # pPartialPath := Whether to start navigation at the current dir or
- # at the desktop
- # 1 - start at current directory
- # 0 - start at desktop
- # pFinalReturn := Whether to accept the final item in <pPathList>
- # Returns: PathList
- #========================================================================
- # History:
- #
- #########################################################################
- TASK SFNavigate( pPathList :={},pTEToggle :=0, pFinalReturn := 1, pPartialPath := 0)
- begin
- # Verify that Standard File is present
- if (IsStandardFile())
- begin
- if (pPathList) # Path list needs to be specified
- begin
- OrigPathList :={}; # Initialize variable
- match[popup i:?Popupitems]; # match SF popup
-
- for x := 1 to (card PopUpItems-1) # Build a Pathlist
- OrigPathList := insert(PopUpItems[x].t,1,OrigPathList);
-
- if (OrigPathList = pPathList) # Is the current directory the desired directory
- pPathList := {};
- else if (TypeOf(pPathList) = "integer") # return to where you started
- begin
- if (pPathList = 1)
- pPathList := Global gSFOriginalPath;
- end;
- else # Update the gobal gSFOriginalPath
- gSFOriginalPath := OrigPathList;
-
- SFPath := '';
- For each item in pPathList # For logging purposes - build pathlist
- SFPath := SFPath + Item + ":";
- LogStr( "Standard File Navigation to the path - ∂[{SFPath}∂]",3);
-
- SFType(pPathList,pTEToggle, pFinalReturn, pPartialPath);
- Return(pPathList);
- end;
- else
- LogStr( "Standard File is set to current default directory",3);
- end;
- else
- return(0);
- end; # SFNavigate()
-
- #########################################################################
- # SFType(pPathList, pTEToggle, pFinalReturn, pPartialPath)
- #========================================================================
- # Author: KTA
- # Description: Performs navigation in Standard File.
- # If <pPartialPath> evaluates to true Selects the 'DeskTop' button.
- # Then types each item in <pPathList>
- # folled by a returnKey.
- # Parameters: pPathList := List of directories beginning with the disk name.
- # pTEToggle := Whether toggling from a text edit field is required
- # to navigate.
- # 1 - Toggle
- # 0 - No toggling required
- # pPartialPath := Whether to start navigation at the current dir or
- # at the desktop
- # 1 - start at current dir
- # 0 - start at desktop
- # pFinalReturn := Whether to accept the final item in <pPathList>
- # Returns: Nada
- #========================================================================
- # History:
- #
- #########################################################################
- TASK SFType(pPathList,pTEToggle :=0, pFinalReturn := 1, pPartialPath := 0)
- begin
- if not (pPartialPath)
- SelectButton('Desktop');
- if (pTEToggle)
- type k:{TabKey}; # Makes directory list active
- wait(2);
- TypeList(pPathList,1,pFinalReturn); # Actual navigation
- if (pTEToggle)
- type k:{TabKey}; # Makes text edit active
- end; # SFType()
-
- #########################################################################
- # ReplaceExist( pReplaceFlag,pNameDoc)
- #========================================================================
- # Author: KTA
- # Description: Handles the 'Replace existing?' dialog.
- # Parameters: pReplaceFlag - Whether to Replace a document with the same name
- # or generate a unique name.
- # 1 - Overwrite document with same name.
- # 0 - Do not overwrite. Generate unique name.
- # pNameDoc := Name of file which already exists on disk.
- # Returns: pNameDoc ( will be identical to the initial one if pReplaceFlag is set)
- #========================================================================
- # History:
- # KTA 8/24/93 TCS stack parity check
- #########################################################################
- TASK ReplaceExist( pReplaceFlag := true, pNameDoc :='')
- begin
- global gIsSys7;
- LogStr(" -- Replace Existing?? --");
- # Different button names on dialog
- myButton := collect[button w:[window o:1]];
- firstButton := MyButton[1];
- secondButton := MyButton[2];
- if (firstButton.r[1] < secondButton.r[1])
- begin
- CancelString := firstButton.t;
- ReplaceString := secondButton.t;
- end;
- else
- begin
- ReplaceString := firstButton.t;
- CancelString := secondButton.t;
- end;
-
- if (pReplaceFlag) # Want to replace
- begin
- TCSStart({ 4, global kTCSetSFSave },"ReplaceExisting"); # Start TCS
- if(SelectButton(ReplaceString))
- returnVal := 1;
- else
- returnVal := 0;
- TCSEnd({ 4, global kTCSetSFSave }, returnVal);
- end;
- else
- begin # Don't want to replace
- TCSStart({ 3, global kTCSetSFSave },"CancelNewName"); # Start TCS
- if(SelectButton(CancelString))
- returnVal := 1;
- else
- returnVal := 0;
-
- TimeString := GetNewFileName(pNameDoc);
- pNameDoc := "{pNameDoc}{TimeString}";
- if(gIsSys7) # 7.0 and 6.0 handle text entry differently in SF
- type k:{rightArrowKey}; # Places I beam after existing text in SF text edit
- TypeStr("{TimeString}"); # append time to pNameDoc in 6.0/7.0
- SpecialKey(returnKey, 'Return key');
- TCSEnd({ 3, global kTCSetSFSave },returnVal);
- end;
- return(pNameDoc);
- end; # ReplaceExist()
-
- #########################################################################
- # GetNewFileName(pFileName, pIncludeNameFlag)
- #========================================================================
- # Author: SL
- # Description: Gets a new file name by concatenating the app name and
- # the current time.
- # Parameters: pFileName - If this parameter is present, this routine will
- # only pass back the time. If this parameter is not
- # present, then this routine will pass back a string
- # consisting of the application name with the time
- # appended to it.
- # pIncludeNameFlag - if true will append time and Sec to end of
- # name and return it.
- # Returns: newFileName - string name for new file name
- # or just a time and Sec string
- #========================================================================
- # History:
- #
- #########################################################################
- TASK GetNewFileName(pFileName :="",pIncludeNameFlag := 0) begin
- Global IsSys7;
- match [time h:?Tm s:?Sc];
- if (pFileName)
- begin
- if(pIncludeNameFlag)
- newFileName := "{pFileName} {Tm}{Sc}";
- else
- newFileName := " {Tm}{Sc}";
- end;
- else
- begin
- match [Application t:?appName];
- newFileName := "@!@{appName}-{Tm}{Sc}";
- end;
- return(newFileName);
- end; # GetNewFileName()
-
- #########################################################################
- # SFSelectPopupMenuItem(pPopupMenuItem)
- #========================================================================
- # Author: Kevin Avoy
- # Description: Selects the popup menu item <pPopupMenuItem> from the Standard
- # File dialog.
- # Parameters: pPopupMenuItem - The ordinality or Title of the menuitem (where
- # the Displayed menuItem is ord 1 if using Ordinality).
- # Returns: nothing
- # Examples: SelectPopupMenuItem("Font");
- # SelectPopupMenuItem(2);
- # Assumptions: The popup menu is in window ord 1
- #========================================================================
- # History:
- #
- #########################################################################
- TASK SFSelectPopupMenuItem( pPopupMenuItem := '')
- begin
- if (IsStandardFile())
- begin
- PopupMenu := match[popup R:?ThePopUpRect i:?PopupMenuItems];
- if (pPopupMenuItem = 0)
- return(1);
- x := ((ThePopUpRect[1]+ThePopUpRect[3])/2);
- y := ((ThePopUpRect[2]+ThePopUpRect[4])/2);
-
- if not(TypeOf(pPopupMenuItem) = 'integer')
- begin
- Match[MenuItem t:/{pPopupMenuItem}≈/ o:?PopUpOrd m:[Popup]];
- pPopupMenuItem := PopUpOrd;
- end;
-
- ### do our own logging
- temp := global gDisableAllLogging;
- global gDisableAllLogging := 1;
- ### Now select menuitem
- MoveMouse(x,y);
- pressMouse;
- wait(1);
- move r: { 0,16 * (pPopupMenuItem - 1) };
- wait(1);
- releaseMouse;
-
- ### restore logging
- global gDisableAllLogging := temp;
- thePopupName := PopupMenuItems[pPopupMenuItem].t;
-
- ### log what just happened
- LogStr("Selected popup menu item ∂'{thePopupName}∂' from the Standard File popUp");
- Return(thePopupName);
- end;
- else
- return(0);
- end;
-
- #########################################################################
- # ModifyDocument()
- #========================================================================
- # Author: KTA
- # Description: This task is called to modify a document so a revert to saved can
- # be performed. If a global tqask reference (gModifyDocument) is
- # defined, it will be called. Otherwise the default of typing a
- # string will be used.
- # Parameters: none
- # Returns: 0 - failure
- # 1 - success
- # Examples: ModifyDocument()
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/30/93 Added returnVal and return
- # KTA 9/28/93 isUndefined(returnVal)
- # KTA 9/28/93 Added TCS - 'Modify a Document'
- # KTA 10/05/93 Change returnVal to a 1 if it was successful
- # KTA 12/14/93 gModifyDoc can return a -1 and test was unsuccessful
- #########################################################################
- TASK ModifyDocument()
- begin
- TCReturnVal := 0;
- ErrStr := "";
- TCSStart({ 1, global kTCSetRevertDoc }, "Modify a Document");
- if (global gModifyDocument)
- begin
- TCReturnVal := call (gModifyDocument);
- if(isUndefined(TCReturnVal)) # If the gModifyDocument hook doesn't return a value
- begin
- ErrStr := "Failed because there was no return value";
- TCReturnVal := 0; # no value returned from hook - have to fail.
- end;
-
- if(TCReturnVal < 1) # if gModifyDoc was successFul
- returnVal := 0; # return a failure
- else
- returnVal := 1; # return a success
- end;
- else
- begin
- TypeStr("If 'Revert' worked, this shouldn't be here!");
- TCReturnVal := 1; #Hopefully this works to modify the document
- returnVal := 1; # return a success
- end;
- TCSEnd({ 1, global kTCSetRevertDoc }, TCReturnVal, ErrStr);
- return(returnVal);
- end;
-
- #########################################################################
- # Revert(pRevertMI)
- #========================================================================
- # Author: KTA
- # Description: If RevertMI is defined as the menuItem for revert it will be selected.
- # Otherwise a menuItem with the word 'Revert' in it will be selected.
- # A dialog will normally appear confirming the revert request.
- # Several methods will be used when attempting to dismiss the dialog.
- # Attempts to matck buttons "OK", "Yes", "Revert", are made, then
- # typing the returnKey. If RevertMi is defined then DialogCheck()
- # Will be called to output the static text in the dialog and the type
- # the returnKey.
- # Parameters: pRevertMI - List containing the ordinality of the revert menuItem.
- # Returns: nada
- # Examples: Revert()
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/12/93 Pass in pRevertMI for intl
- # KTA 8/24/93 TCS stack parity check
- # KTA 10/15/93 Added longer wait before trying to dismiss dialog and
- # support for hierachical menus
- #########################################################################
- TASK Revert(pRevertMI := '')
- begin
- global gApptitle;
- returnVal := 0;
- failStr := '';
- TCSStart({ 2, global kTCSetRevertDoc },"Revert"); # Start TCS
- if (pRevertMI = '')
- begin
- if(match [menu t:'File' i:{ [menuItem t:/Revert≈(≈∂n≈)*/ e:true o:?ord] } ]!)
- begin
- match [menu t:'File' i:{ [menuItem t:?item e:true o:ord] } ]!;
- SelectMenuItem(item,'File');
- if match [button t:'OK']
- SelectButton('OK');
- else if match [button t:'Yes']
- SelectButton('Yes');
- else if match [button t:'Revert']
- SelectButton('Revert');
- else # try default if no 'yes' or 'OK' button
- SpecialKey(returnKey, 'Return key');
- DialogReturn := DialogCheck("",1);
- if(DialogReturn)
- failStr := DialogReturn;
- else
- returnVal := 1;
- end;
- end;
- Else if(TypeOf(pRevertMI) = 'list') # Pass in Ord for (Intl)
- begin
- if (Card(pRevertMI) = 2)
- returnVal := SelectMenuItem(pRevertMI[1], pRevertMI[2]);
- else if (Card(pRevertMI) = 3)
- returnVal := SelectMenuItem(pRevertMI[1], pRevertMI[2], pRevertMI[3]);
- Wait(2);
- DialogCheck("",1); # Dismiss the Revert Dialog
- end;
- else
- begin
- failStr := "There is no enabled menu item titled 'Revert' in {gApptitle}";
- logstr(failStr);
- end;
- TCSEnd( { 2, global kTCSetRevertDoc }, returnVal, failStr);
- end;
-
- #########################################################################
- # IsStandardFile(pLogIt)
- #========================================================================
- # Author: KTA
- # Description: Checks to see if the Standard File dialog is present
- # Parameters: pLogIt - Flag indicating whether or not to output
- # the nonexistence of the StandardFile dialog.
- # Returns: 1 - if the Standard File dialog is present
- # 0 - if the Standard File dialog is not present
- # Examples: IsStandardFile()
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/7/93 Added enhanced check for StandardFile for intl systems
- # KTA 7/29/93 If StandardFile return a window descriptor of front window
- #########################################################################
- TASK IsStandardFile(pLogIt := 1)
- begin
- returnVal := 0;
- SF_Dialog := match[button t:/≈Desktop≈/]!;
- if (SF_Dialog)
- returnVal := match[window o:1]!;
- else
- begin
- NumButtons := collect[button];
- NumUserItem := collect[useritem];
- if((Card(NumButtons) >= 4) and (Card(NumUserItem) >= 1))
- returnVal := match[window o:1]!;
- end;
- if not(returnVal) and (pLogIt)
- LogStr( "The Standard_File dialog is not present");
-
- return(returnVal);
- end;
-
- #########################################################################
- # CancelStandardFile(pHowCancel, pSaveAsMenu)
- #========================================================================
- # Author: KTA
- # Description: Selects Save As and Cancels it
- # Parameters: pHowCancel - method to cancel
- # 0 := KeyEq('.');
- # 1 := selectButton('Cancel');
- # 2 := SpecialKey(escapeKey,"Escape key");
- # pSaveAsMenu - list containing the ordinality of 'Save As' menu item.
- # - anything else will cause the hardcoded string 'Save As'
- # to be use in matching the menuItem.
- # Returns: 1 - if cancelling occured as expected
- # 0 - if it didn't
- # Examples: CancelStandardFile()
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/8/93 Added pHowCancel method 2 := escapekey
- # KTA 7/8/93 Added pSaveAsMenu the SaveAs menu descriptor
- # KTA 8/24/93 TCS stack parity check
- #########################################################################
- TASK CancelStandardFile(pHowCancel := 0, pSaveAsMenu := 0)
- begin
- failStr := "";
- returnVal := 0;
-
- if(pHowCancel = 1)
- TCSNum := 5;
- else
- TCSNum := 6;
-
- TCSStart({ TCSNum, global kTCSetSFSave },"SaveAs/Cancel"); # Start TCS
- if (TypeOf(pSaveAsMenu) = 'list')
- SelectMenuItem(pSaveAsMenu[1],pSaveAsMenu[2]); ## Save/Cancel
- else
- SelectMenuItem("Save As",'File'); ## Save/Cancel
- wait(3);
- if(IsStandardFile()) # Check to see if standard file is present
- begin
- if(pHowCancel = 0)
- KeyEq('.');
- else if(pHowCancel = 1)
- begin
- if (match[button t:'Cancel'])
- selectButton('Cancel'); # Cancel the Standard SF_Put Dialog
- else
- begin
- SpecialKey(escapeKey,"Escape key"); # Help insure success - (intl)
- failStr := "No 'Cancel' button found - Hit the escape key instead.";
- end;
- end;
- else if(pHowCancel = 2)
- SpecialKey(escapeKey,"Escape key");
-
- if not(IsStandardFile(0)) # Check to see if standard file is not present
- returnVal := 1;
- else
- failStr := "Standard_File is still present and shouldn't be";
- end;
- TCSEnd({ TCSNum, global kTCSetSFSave }, returnVal,failStr);
- return(returnVal);
- end;
-
- #########################################################################
- # Save(pSaveMethod)
- #========================================================================
- # Author: KTA
- # Description: Selects Save - calls Save As if Standard File appears
- # Parameters: pSaveMethod - Method to save
- # 1 := Save from File Menu
- # 2 := Command-'s'
- # Returns: Nothing
- # Examples: Save()
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/8/93 Added pSaveMethod input parameter & pSaveMethod(2)
- # KTA 8/24/93 TCS stack parity check
- #########################################################################
- TASK Save(pSaveMethod := 1)
- begin
- if(pSaveMethod = 1)
- begin
- if (match[menuItem t:'Save' m:[menu t:'File' e:true] e:true]!)
- begin
- TCSStart({ 7, global kTCSetSFSave },"Save using Save menu item"); # Start TCS
- TCSEnd({ 7, global kTCSetSFSave }, SelectMenuItem("Save",'File'));
- if(isStandardFile(0)) # if StandardFile is present
- begin
- SaveAs(); # Call SF handler
- end;
- end;
- else
- pSaveMethod := 2; # Help insure success (intl)
- end;
- if(pSaveMethod = 2)
- keyEq('s');
- end;
-